﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using RimWorld;
using Verse.AI;
namespace Miao.Stand
{
    public class CompProperties_SheeHeartAttackCompToken : CompProperties
    {
        public CompProperties_SheeHeartAttackCompToken()
        {
            compClass = typeof(SheeHeartAttackCompToken);
        }
    }

    public class SheeHeartAttackCompToken : CompToken
    {
        public float explosionRadius;
        public override void PostExposeData()
        {
            Scribe_Values.Look<float>(ref explosionRadius, "explosionRadius");
            base.PostExposeData();
        }
        public override void CompTickRare()
        {
            base.CompTickRare();

        }

        public override void PostDestroy(DestroyMode mode, Map previousMap)
        {
          
            base.PostDestroy(mode, previousMap);
            if (mode == DestroyMode.KillFinalize)
            {
                self.Corpse.Destroy();
                Messages.Message("枯萎穿心攻击被彻底摧毁了".Translate(), MessageTypeDefOf.PawnDeath);
                foreach (var body in owner.def.race.body.AllParts)
                {
                    foreach (BodyPartGroupDef bd in body.groups)
                    {
                        if (bd == BodyPartGroupDefOf.LeftHand)
                        {

                            DamageInfo damageInfo = new DamageInfo(DamageDefOf.Bomb, 30, 1, 0, null, body.parent, null);
                            owner.owner.TakeDamage(damageInfo);
                            return;
                        }
                    }
                }
            }
        }
    }
}
